package Classes.GameViews.ViewPanels
{
	import Classes.GameUtils.GU_NewThingsControler;
	import Classes.GameUtils.GU_NewThingsInfo;
	import Classes.GameViews.ViewScenes.VS_Main;
	import Classes.Managers.M_ConfigData;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.system.ApplicationDomain;

	/**
	 * 头部有动态星星的弹出窗口 
	 * @author Administrator
	 */	
	public class VP_beathartWindon extends ViewPanel
	{
		private var _interfaceUI:Sprite;
		private var dobj:DisplayObject;
		
		private var newThingsType:int=-1;
		
		public function VP_beathartWindon()
		{
			this.init();
		}
		
		private function init():void
		{
			this._interfaceUI=new (ApplicationDomain.currentDomain.getDefinition("BeathartWindon_v") as Class);
			dobj=this.addChild(this._interfaceUI);
			this.addListener();
		}
		
		/**
		 * 完成任务 关闭任务面板 
		 */		
		public function openBeathartWin():void
		{
			this.openAt(VS_Main.instance,true);
			this.toCenter();
		}

		private function addListener():void
		{
			this.addEventListener("close",closeHandler);
			this.addEventListener("shareNewThings",shareNewThings);
		}
		
		private function closeHandler(e:Event):void
		{
			this.closeWin();
		}
		
		/**
		 * 分享 功能
		 * @param e
		 * 
		 */		
		private function shareNewThings(e:Event):void
		{
			if(M_ConfigData.instance.isOpenNewThing)
			{
				new GU_NewThingsControler(GU_NewThingsInfo.instance.getNewThingsByType(this.newThingsType));
//				M_Communication.instance.send(125000);
			}
			this.closeWin();
		}
		/**
		 * 弹出窗口
		 * @param obj 数据源 windonIconTitle,windonContext,rewardTxt,CenterBtnTxt,items[num,lock,pic]
		 * @param newThingType 新鲜事类型
		 * @param isHideStar 隐藏窗口跳动星星的头部
		 * @param isHideHead 隐藏窗口内部横条
		 */		
		public function setWinInfo(obj:Object,newThingType:int,isHideStar:Boolean=true,isHideHead:Boolean=true):void
		{
			this.newThingsType=newThingType;
			this._interfaceUI["setWindonHeadVisabe"](isHideStar,isHideHead);
			this._interfaceUI["setWinInfo"](obj);
			this.openBeathartWin();
				
		}
		
		/**
		 *关闭界面 
		 * 
		 */		
		public function closeWin():void
		{
			this.removeChild(_interfaceUI);
			this._interfaceUI=null;
			this.removeEventListener("close",closeHandler);
			this.removeEventListener("shareNewThings",shareNewThings);
			this.close();
			
		}

	}
}